package cn.itcast.zt.java8.stream;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

/**
 * 重写equal和hashcode方法
 * create by zhangtian105 on 2022/3/27
 */
@Setter
@Getter
@AllArgsConstructor
public class PersonBean {
    private Long id;
    private String name ;

    @Override
    public String toString() {
        return "PersonBean{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        PersonBean that = (PersonBean) o;

        if (id != that.id) return false;
        return name != null ? name.equals(that.name) : that.name == null;
    }

    @Override
    public int hashCode() {
        int result = (int) (id ^ (id >>> 32));
        result = 31 * result + (name != null ? name.hashCode() : 0);
        return result;
    }
}
